package com.hai.qtalk.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.hai.qtalk.bean.Group;
import com.hai.qtalk.bean.User;

/**
 * 描述用户之间关系的实体类
 * @author xinhai
 */
@Entity
@Table(name = "friendship", catalog = "mydb")
public class Friendship implements java.io.Serializable {

	// Fields

	private Integer FId;
	private Group group;//null表示黑名单，其它为用户后来新建并命名的分组,如果找不到用户的任何好友分组会在客户端另外处理，建个未分组，不占用数据库
	private User userByFriendId;
	private User userByHostId;
	private String friendRemark;

	// Constructors

	/** default constructor */
	public Friendship() {
	}

	/** full constructor */
	public Friendship(Group group, User userByFriendId, User userByHostId,
			String friendRemark) {
		this.group = group;
		this.userByFriendId = userByFriendId;
		this.userByHostId = userByHostId;
		this.friendRemark = friendRemark;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "f_id", unique = true, nullable = false)
	public Integer getFId() {
		return this.FId;
	}

	public void setFId(Integer FId) {
		this.FId = FId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "g_id")
	public Group getGroup() {
		return this.group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "friend_id")
	public User getUserByFriendId() {
		return this.userByFriendId;
	}

	public void setUserByFriendId(User userByFriendId) {
		this.userByFriendId = userByFriendId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "host_id")
	public User getUserByHostId() {
		return this.userByHostId;
	}

	public void setUserByHostId(User userByHostId) {
		this.userByHostId = userByHostId;
	}

	@Column(name = "friend_remark", length = 45)
	public String getFriendRemark() {
		return this.friendRemark;
	}

	public void setFriendRemark(String friendRemark) {
		this.friendRemark = friendRemark;
	}

}